#!/bin/bash
cd /home/storm/kafka-dbsync-service/
case "$1" in

  start)  
  if [ ! -f "server.pid" ]; then
    nohup java -Djava.ext.dirs=./lib com.linkstec.mot.main.syncApplicationStarter >/dev/null 2>&1 &
    echo $! > server.pid
    echo '启动kafka-db同步服务'
	echo `cat server.pid`
    
  else
    echo 'kafka-db同步已经启动'
  fi
  ;;
  
  stop)  
    kill `cat server.pid`
    rm -rf server.pid
    echo '停止kafka-db同步服务'
    ;;

  restart)
    $0 stop
    sleep 1
    $0 start
    echo '重启kafka-db同步服务'
    ;;

  status)
  if [ -f "server.pid" ]; then
    echo '运行中'
  else
    echo '已停止'
  fi
  ;;

  *)
    echo "Usage: run.sh {start|stop|restart|status}"
    ;;


esac

exit 0
